﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Procedure = DeltaFlex.Data.ConsProcedures.Usuari;

namespace DeltaFlex.Data
{
    public class Usuari
    {
        public Usuari()
        { }

        #region Selects
        public static IDataReader CercarRolUsuariByDNI(string dni)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = Procedure.SP_CERCAR_ROL_USUARI_BY_DNI;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_DNIUSUARI, dni);

            return Operacions_BD.Reader(cmd);
        }
        #endregion

        #region Updates
        public static void ActualitzaDarrerAccesUsuari(int idUsuari)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = Procedure.SP_ACTUALITZAR_DARRER_ACCES_USUARI;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDUSUARI, idUsuari);

            Operacions_BD.Update(cmd);
        }
        #endregion
    }
}
